<?php
/***************************************************************************
 *
 *   copyright            : (C) 2005 Winds of Storm
 *
 *   $Id: admin.php,v 1.6 2007/02/11 12:24:26 nonny Exp $
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

$auth	= 'false';

//
// Support working in phpsuexec mode
//
if (isset($_SERVER["HTTP_AUTHORIZATION"]) && !empty($_SERVER["HTTP_AUTHORIZATION"])) {
	list ($type, $cred) = split (" ", $_SERVER['HTTP_AUTHORIZATION']);
	
	if ($type == 'Basic') {
		list ($user, $pass) = explode (":", base64_decode($cred));
	}
} else if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
	$user	= $_SERVER['PHP_AUTH_USER'];
	$pass	= $_SERVER['PHP_AUTH_PW'];
}

$res	= checkAuth($user, $pass, -1, 1);
if (is_array($res)) {
	$auth	= 'true';
} else {
	$auth	= 'false';
}

if ($auth == 'false') {
	Header('WWW-Authenticate: Basic realm="StormChat Admin - ' . $config['FORUM_NAME'] . '"');
	Header('HTTP/1.0 401 Unauthorized');
	print('Authorization Required.');
	exit;
}

$admin_header	= 1;
showHeader($body, $header);

